<template>
{{#if ctrl.psSysPFPlugin}}
    {{> @macro/plugins/widget/widget-use.hbs appPlugin=ctrl.psSysPFPlugin}}
{{else}}
  <div :class="classNames">
    <component
      :is="model.embedViewCodeName"
      :name="model.embedViewCodeName"
      :context="store.context"
      openType="EMBED"
      :viewParams="store.viewParams"
      :singleSelect="singleSelect"
      @view-init="(name: string, data: any) => handleCtrlInit(controller, name, data)"
      @view-action="(name: string, action: string, data: IParam[]) => handleCtrlAction(controller, name, action, data)">
    </component>
  </div>
{{/if}}
</template>
<script setup lang="ts">
// 基于template/src/widgets/\{{appEntities}}/\{{ctrls@PICKUPVIEWPANEL}}-pickup-view-panel/\{{ctrls@PICKUPVIEWPANEL}}-pickup-view-panel.vue.hbs生成
{{> @macro/plugins/widget/widget-import.hbs ctrl=ctrl}}
import { IContext, IParam, PickupViewPanelActionType, IPickupViewPanelAbility, IPickupViewPanelControllerParams, IPickupViewPanelStore, PickupViewPanelController, ILoadingHelper, createUUID, IViewCtx } from '@/core';
import { useNavParamsBind, useEventBind, getCtrlClassNames, handleCtrlAction, handleCtrlInit } from '@/hooks/use-ctrl';
import { model } from "./{{spinalCase ctrl.codeName}}-pickup-view-panel-model";
{{> @macro/widgets/ctrl/ctrl-props.hbs
    props="openView?: Function;
    newView?: Function;
    singleSelect?: boolean;
    "
}}

{{> @macro/common/emit.hbs name="ctrl" actionType="PickupViewPanelActionType" ability="IPickupViewPanelAbility"}}
//  部件样式名
const classNames = computed(() => {
  return getCtrlClassNames(model, props);
});

const controlID = 'id' + createUUID();   

const params: IPickupViewPanelControllerParams<PickupViewPanelActionType, IPickupViewPanelAbility> = {
    name: props.name,
    model,
    evt,
    controlID, 
    actions: {},
    openView: props.openView,
    newView: props.newView,
    closeView: props.closeView,
    pLoadingHelper: props.pLoadingHelper,
    pViewCtx: props.pViewCtx,
    handler: (data: IPickupViewPanelStore) => { return reactive(data) }
};
//  选择视图面板控制器
const controller = new PickupViewPanelController(params);
useNavParamsBind(controller, props);

const store = controller.getStore();

</script>
